package com.hospital.controller;

import com.hospital.domain.DTO.PatientDTO;
import com.hospital.domain.pojo.Doctor;
import com.hospital.domain.pojo.Patient;
import com.hospital.domain.utils.Result;
import com.hospital.service.DoctorService;
import com.hospital.service.PatientService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/patient")
@Tag(name = "病人接口", description = "无")
public class PatientController {

private final PatientService patientService;

    @Operation(summary = "查看病人信息")
    @GetMapping("/info/{pId}")
    public Result getPatient(@PathVariable("pId") Integer pId){
        Patient patient = patientService.lambdaQuery().eq(Patient::getPId, pId).one();
        return Result.ok(patient);
    }

    @Operation(summary = "查询所有患者信息")
    @GetMapping("/query")
    public Result<List<Patient>> getAllPatients(){
        List<Patient> patients = patientService.list();
        return Result.ok(patients);
    }

    @Operation(summary = "注册病人账号")
    @PostMapping("/signup")
    public Result signupPatient(@RequestBody PatientDTO patientDTO){
        return patientService.signupPatient(patientDTO.getName(), patientDTO.getCardId(), patientDTO.getPhone(), patientDTO.getPw(), patientDTO.getState());
    }

}
